import time
from selenium.webdriver.common.by import By
from Page.Page import Page
class Page1(Page):
    #对写信进行元素定位  id="_mail_component_98_98"
    # _mail_component_98_98
    write_loc=(By.ID,'_mail_component_98_98')
    #封装写信的方法
    def write(self):
        self.click(self.write_loc)

    #对收件人进行定位 class="dG0"
    name_loc=(By.CLASS_NAME,'nui-editableAddr-ipt')
    #对收件人进行输入操作
    def name(self):
        self.send_key(self.name_loc,'2200137015@qq.com')

    #对主题进行定位  //*[@id="1754898539135_subjectInput"]
    subject_loc=(By.XPATH,'/html/body/div[2]/div[1]/div/div[1]/section/header/div[2]/div[1]/div/div/input')
    #对主题进行输入操作
    def subject(self):
        self.send_key(self.subject_loc,'webui自动化测试')

    #对发送进行定位  class="nui-btn-text"  id="_mail_icon_35_258"
    # send_loc=(By.XPATH,'//b[starts-with(@id,"_mail_icon_")]')
    send_loc=(By.CLASS_NAME,'nui-btn-icon')
    #对存草稿进行点击操作
    def send(self):
        self.click(self.send_loc)

    #对发送邮件成功进行断言
    # dy1_loc=(By.LINK_TEXT,'查看已发邮件')
    #封装断言的方法
    # def dy1(self):
    #     self.get_text(self.dy1_loc)

    #逻辑
    def write_luoji(self):
        self.login_email_luoji()
        self.write()
        self.name()
        time.sleep(3)
        self.subject()
        time.sleep(3)
        self.send()
        time.sleep(5)
        self.switch_to()
        # print(self.dy1())
        # assert "查看已发邮件" in self.dy1()


